###############################################################################
# TabMenu.pl                                                                  #
###############################################################################
# YaBB: Yet another Bulletin Board                                            #
# Open-Source Community Software for Webmasters                               #
# Version:        YaBB 2.2                                                    #
# Packaged:       November 8, 2007                                            #
# Distributed by: http://www.yabbforum.com                                    #
# =========================================================================== #
# Copyright (c) 2000-2007 YaBB (www.yabbforum.com) - All Rights Reserved.     #
# Software by:  The YaBB Development Team                                     #
#               with assistance from the YaBB community.                      #
# Sponsored by: Xnull Internet Media, Inc. - http://www.ximinc.com            #
#               Your source for web hosting, web design, and domains.         #
###############################################################################

$tabmenuplver = 'YaBB 2.2 $Revision: 1.18 $';
if ($action eq 'detailedversion') { return 1; }

sub mainMenu {
	my($homeclass, $helpclass, $searchclass, $memberlistclass, $favoritesclass, $loginclass, $sessionclass, $registerclass, $profileclass, $notificationclass, $logoutclass, $guestpmclass);
	
	if ($action ne "") {
		if ($action eq "help") { $helpclass = qq~ class="selected"~; }
		elsif ($action eq "search" || $action eq "search2") { $searchclass = qq~ class="selected"~; }
		elsif ($action eq "ml") { $memberlistclass = qq~ class="selected"~; }
		elsif ($action eq "login") { $loginclass = qq~ class="selected"~; }
		elsif ($action eq "revalidatesession") { $sessionclass = qq~ class="selected"~; }
		elsif ($action eq "register") { $registerclass = qq~ class="selected"~; }
		elsif ($action eq "mycenter" || $action eq "favorites" || $action eq "shownotify" || $action eq "im" || $action eq "imdraft" || $action eq "imoutbox" || $action eq "imstorage" || $action eq "imsend" || $action eq "imsend2" || $action eq "imshow" || $action eq "profileCheck" || $action eq "myviewprofile" || $action eq "myprofile" || $action eq "myprofileContacts" || $action eq "myprofileOptions" || $action eq "myprofileBuddy" || $action eq "myprofileIM" || $action eq "myprofileAdmin") { $userclass = qq~ class="selected"~; }
		elsif ($action eq "logout") { $logoutclass = qq~ class="selected"~; }
		elsif ($action eq "messagepagetext" || $action eq "messagepagedrop" || $action eq "threadpagetext" || $action eq "threadpagedrop") { $homeclass = qq~ class="selected"~; }
		elsif ($action eq "guestpm" || $action eq "guestpm2") { $guestpmclass = qq~ class="selected"~; }
	}
	else {
		$homeclass = qq~ class="selected"~;
	}
	
	$tabsep = qq~<img src="$imagesdir/tabsep211.png" border="0" alt="" style="float: left; vertical-align: middle;" />~;
	$tabfill = qq~<img src="$imagesdir/tabfill.gif" border="0" alt="" style="vertical-align: middle;" />~;
	
	$yytabmenu .= qq~$tabsep<span onclick="location.href='$scripturl';"$homeclass><a href="$scripturl" title = "$img_txt{'103'}">$tabfill$img_txt{'103'}$tabfill</a></span>~;
	$yytabmenu .= qq~$tabsep<span onclick="location.href='$scripturl?action=help';" style="cursor:help;"$helpclass><a href="$scripturl?action=help" title = "$img_txt{'119'}" style="cursor:help;">$tabfill$img_txt{'119'}$tabfill</a></span>~;
	if ($maxsearchdisplay > -1) {
		$yytabmenu .= qq~$tabsep<span onclick="location.href='$scripturl?action=search';"$searchclass><a href="$scripturl?action=search" title = "$img_txt{'182'}">$tabfill$img_txt{'182'}$tabfill</a></span>~;
	}
	if ((!$ML_Allowed && $iamguest) || ($ML_Allowed == 1 && !$iamguest) || ($ML_Allowed == 2 && $staff) || ($ML_Allowed == 3 && ($iamadmin || $iamgmod))) {
		$yytabmenu .= qq~$tabsep<span onclick="location.href='$scripturl?action=ml';"$memberlistclass><a href="$scripturl?action=ml" title = "$img_txt{'331'}">$tabfill$img_txt{'331'}$tabfill</a></span>~;
	}
	if ($iamadmin) {
		$yytabmenu .= qq~$tabsep<span><a href="$boardurl/AdminIndex.$yyaext" title = "$img_txt{'2'}">$tabfill$img_txt{'2'}$tabfill</a></span>~;
	}
	if ($iamgmod) {
		if (-e ("$vardir/gmodsettings.txt")) {
			require "$vardir/gmodsettings.txt";
		}
		if ($allow_gmod_admin) {
			$yytabmenu .= qq~$tabsep<span><a href="$boardurl/AdminIndex.$yyaext" title = "$img_txt{'2'}">$tabfill$img_txt{'2'}$tabfill</a></span>~;
		}
	}
	if ($sessionvalid == 0 && !$iamguest) {
		$sesredir = "";
		unless($action eq "revalidatesession" || $action eq "revalidatesession2") {
			$sestestenv = $testenv;
			$sestestenv =~ s/\=/\~/g;
			$sestestenv =~ s/;/x3B/g;
			if($sestestenv) { $sesredir = qq~;sesredir=$sestestenv~; }
		}
		$yytabmenu .= qq~$tabsep<span onclick="location.href='$scripturl?action=revalidatesession$sesredir';"$sessionclass><a href="$scripturl?action=revalidatesession$sesredir" title = "$img_txt{'34a'}">$tabfill$img_txt{'34a'}$tabfill</a></span>~;
	}
	if ($iamguest) {
		$yytabmenu .= qq~$tabsep<span onclick="location.href='$scripturl?action=login';"$loginclass><a href="$scripturl?action=login" title = "$img_txt{'34'}">$tabfill$img_txt{'34'}$tabfill</a></span>~;
		if (!$regdisable) {
			$yytabmenu .= qq~$tabsep<span onclick="location.href='$scripturl?action=register';"$registerclass><a href="$scripturl?action=register" title = "$img_txt{'97'}">$tabfill$img_txt{'97'}$tabfill</a></span>~;
		}
		if ($PMenableGuestButton && $PM_level  != 0) {
			$yytabmenu .= qq~$tabsep<span onclick="location.href='$scripturl?action=guestpm';"$guestpmclass><a href="$scripturl?action=guestpm" title = "$img_txt{'pmadmin'}">$tabfill$img_txt{'pmadmin'}$tabfill</a></span>~;
		}
	}
	else {
		$yytabmenu .= qq~$tabsep<span onclick="location.href='$scripturl?action=mycenter';"$userclass><a href="$scripturl?action=mycenter" title = "$img_txt{'mycenter'}">$tabfill$img_txt{'mycenter'}$tabfill</a></span>~;
		$yytabmenu .= qq~$tabsep<span onclick="location.href='$scripturl?action=logout';"$logoutclass><a href="$scripturl?action=logout" title = "$img_txt{'108'}">$tabfill$img_txt{'108'}$tabfill</a></span>~;
	}
	
	$yytabmenu .= qq~$tabsep~;
}

sub mcMenu	{
	my ($display_prof, $display_posts, $display_pm, $tabPMHighlighted, $tabProfHighlighted, $tabNotifyHighlighted);

	my ($pmclass, $profclass, $postclass);
	if ($action eq "mycenter" || $action eq "im" || $action eq "imdraft" || $action eq "imoutbox" || $action eq "imstorage" || $action eq "imsend" || $action eq "imsend2" || $action eq "imshow") {
		$pmclass = qq~ class="selected"~;
		if ($PM_level == 0 || ($PM_level == 2 && !$iamadmin && !$iamgmod && !$iammod ) || ($PM_level == 3 && !$iamadmin && !$iamgmod)) {
			$profclass = qq~ class="selected"~;
		}
	}

	if ($action eq "profileCheck" || $action eq "myviewprofile" || $action eq "myprofile" || $action eq "myprofileContacts" || $action eq "myprofileOptions" || $action eq "myprofileBuddy" || $action eq "myprofileIM" || $action eq "myprofileAdmin") {
		$profclass = qq~ class="selected"~;
	}

	if ($action eq "favorites" || $action eq "shownotify" || $action eq "myusersrecentposts") {
		$postclass = qq~ class="selected"~;
	}

	$tabsep = qq~<img src="$imagesdir/tabsep211.png" border="0" alt="" style="float: left; vertical-align: middle;" />~;
	$tabfill = qq~<img src="$imagesdir/tabfill.gif" border="0" alt="" style="vertical-align: middle;" />~;

	# pm link
	if($PM_level == 1 || ($PM_level == 2 && ($iamadmin || $iamgmod || $iammod)) || ($PM_level == 3 && ($iamadmin || $iamgmod))   )	{
		$yymcmenu .= qq~$tabsep<span onclick="changeToTab('pm'); return false;"$pmclass id="menu_pm"><a href="$scripturl?action=mycenter" onclick="changeToTab('pm'); return false;">$tabfill$mc_menus{'messages'}$tabfill</a></span>
		~;
	}
	# profile link
	$yymcmenu .= qq~$tabsep<span onclick="changeToTab('prof'); return false;"$profclass id="menu_prof"><a href="$scripturl?action=myviewprofile;username=$useraccount{$username}" onclick="changeToTab('prof'); return false;">$tabfill$mc_menus{'profile'}$tabfill</a></span>
	~;

	# posts link
	$yymcmenu .= qq~$tabsep<span onclick="changeToTab('posts'); return false;"$postclass  id="menu_posts"><a href="$scripturl?action=favorites" onclick="changeToTab('posts'); return false;">$tabfill$mc_menus{'posts'}$tabfill</a></span>
	~;

	$yymcmenu .= qq~$tabsep~;
}

1;